
import vue from '@vitejs/plugin-vue';
import { defineConfig, loadEnv, type ConfigEnv } from 'vite';
import vueJsx from '@vitejs/plugin-vue-jsx'

// const root = process.cwd()
// const env = loadEnv(process.argv[process.argv.length - 1], root)

// https://vitejs.dev/config/
export default defineConfig((mode:ConfigEnv)=>{
  const env = loadEnv(mode.mode, process.cwd());
  return {
    plugins: [vue(), vueJsx()],
    server: {
      
      port: Number(env.VITE_PORT),
      open: Boolean(env.VITE_OPEN),
      proxy: {
        [env.VITE_BASE_URL]: {
          // target: 'http://gmall-h5-api.atguigu.cn',
          target:'http://sph-h5-api.atguigu.cn',
          changeOrigin: true,
          rewrite: (path) => path.replace(new RegExp(`^${env.VITE_BASE_URL}`), ''),
        },
      },
    },
  }
})
